<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/jsp/cortop.jsp" %>
<%@ include file="/jsp/jscommom.jsp"%>
<%@ include file="/jsp/viewtop.jsp"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>修改职位信息</title>
<link href="/css/login.css" rel="stylesheet" type="text/css" />
</head>

<%
String station = request.getAttribute("station").toString();
String subStation = request.getAttribute("subStation").toString();
String positionId = request.getParameter("positionId");
 %>
<script language="javascript">
var stationTemp = "<%=station %>";
var subStationTemp = "<%=subStation%>";
<bean:write name="com_struts_web_corpor_manage_infomanage_AddPoForm" property="printStaSql" filter="false"/>
<bean:write name="com_struts_web_corpor_manage_infomanage_AddPoForm" property="printSubStaSql" filter="false"/>
//定义一个变量用于存放XMLHttpRequest对象
	var xmlHttp; 
	
	//该函数用于创建一个XMLHttpRequest对象
	function createXMLHttpRequest() {
		if (window.ActiveXObject) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		else if (window.XMLHttpRequest) {
			xmlHttp = new XMLHttpRequest();
		}
	}

	
	//这是响应列表的onChange事件的处理方法
	function updateSelect(){
		var selected = document.all.stations.value;//得到省份列表的当前选值
		//创建一个XMLHttpRequest对象
		createXMLHttpRequest();
		
		//通过GET方法向指定的URL建立服务器的调用
		xmlHttp.open("GET", "/SubStationXML?selected="+selected);
		//将状态触发器绑定到一个函数
		xmlHttp.onreadystatechange = processor;
		//发送请求
		xmlHttp.send(null);
	}
	
	//处理从服务器返回的XML文档并更新列表
	function processor() {
		//定义一个变量用于存放从服务器返回的响应结果
		var result;
		if(xmlHttp.readyState == 4) { //如果响应完成
			if(xmlHttp.status == 200) {//如果返回成功
				//取出服务器返回的XML文档的所有标签的子节点
				result = xmlHttp.responseXML.getElementsByTagName("sub");
				//先清除列表的现有内容
				while (document.all.subStation.options.length>0){
					document.all.subStation.removeChild(document.all.subStation.childNodes[0]);
				}
				//解析XML中的数据并更新
				for(var i=0;i<result.length;i++){
					var option = document.createElement("OPTION");
					option.text = result[i].childNodes[0].childNodes[0].nodeValue;//这就是取出值
					option.value = result[i].childNodes[1].childNodes[0].nodeValue;//这就是取出值
					
					document.all.subStation.options.add(option);//为岗位列表添加
				}
			}
		}
	}
	
	function doedit(){
	
	   if(document.all.stations.value=="" || document.all.subStation.value==""){
	      alert("对不起,工作岗位选择不能为空!");
	      return;
	   }
	   
	   if(document.all.positionName.value==""){
	      alert("对不起,职位名称不能为空!");
	      return;
	   }
	
	   if(document.all.positionName.value==""){
	      alert("对不起,职位名称不能为空!");
	      return;
	   }
	   if(document.all.startIssueDate.value=="" || document.all.endIssueDate.value==""){
	      alert("对不起,招聘日期不能为空!");
	      return;
	   }
	   if(document.all.requirement.value==""){
	      alert("对不起,职位要求不能为空!");
	      return;
	   }
	   document.all.method.value="edit";
	   document.forms[0].submit();
	   document.all.method.value="";
	
	}
</script>
<body>
<html:javascript formName="com_struts_web_corpor_manage_infomanage_AddPoForm"/>
<html:form action="/com/corpor/manage/editpo" method="post">
  <html:hidden property="method"/>
  <input type="hidden" name="positionId" value="<%=positionId %>"/>
  <div align="center">
  
    <table width="880" border="0" align="center" cellpadding="0"
					cellspacing="1" class="line1">
    <tr>
    <td class="titlebg" colspan="2">
    
    新增职位
    </td>
    </tr>
    
    <tr>
    <td class="mtdtitle1">
    *工作岗位:
    </td>
    <td class="mtdtextleft">
    <html:select property="stations" onchange="updateSelect()" styleClass="input1">
    <SCRIPT language="JavaScript">
			        for (var i = 0; i < (station.length); i++) {
			         document.write("<OPTION value='"+station[i]+"' ");
			         if(station[i]==stationTemp){
			         
			         document.write("selected");
			         }
			    document.write(">" + station[++i]+"</OPTION>");	
			  }
			</SCRIPT>
    </html:select>
    －
    <html:select property="subStation" styleClass="input1">
    <SCRIPT language="JavaScript">
			        for (var i = 0; i < (subStation.length); i++) {
			         document.write("<OPTION value='"+subStation[i]+"' ");
			         if(subStation[i]==subStationTemp){
			         document.write("selected");
			         }
			    document.write(">" + subStation[++i]+"</OPTION>");
			  }
			</SCRIPT>
    </html:select>
    </td>
    </tr>
    
    <tr>
    <td class="mtdtitle1">
    *职位名称:
    </td>
    <td class="mtdtextleft">
    <html:text property="positionName" styleClass="input1"></html:text>
    </td>
    </tr>
    
    <tr>
    <td class="mtdtitle1">
    *招聘时间:
    </td>
    <td class="mtdtextleft">
    从<html:text property="startIssueDate" onclick="datepopup(this)" styleClass="input1"></html:text>到<html:text styleClass="input1" property="endIssueDate" onclick="datepopup(this)"></html:text>
    </td>
    </tr>
    <!--  
    <tr>
    <td class="mtdtitle1">
    *职位描述:
    </td>
    <td class="mtdtextleft">
    <html:textarea property="descript" cols="100%" styleClass="input1"></html:textarea>
    </td>
    </tr>
    -->
    
    <tr>
    <td class="mtdtitle1">
    *职位要求:
    </td>
    <td class="mtdtextleft">
     <html:textarea property="requirement" cols="100%" styleClass="input1"></html:textarea>
    </td>
    </tr>
    
    <tr>
    <td class="mtdtitle1" colspan="2">
    <input type="button" class="tbutton"  value="提交" onclick="doedit()"/>
    <input type="reset" class="tbutton"  value="重置"/>
    <input type="button" class="tbutton"  value="关闭" onclick="window.close();"/>
    </td>
    </tr>
    </table>
  </div>
</html:form>

</body>
</html>
